﻿using IServices;
using Microsoft.AspNetCore.Mvc;
using YL.Core.Dto;
using YL.NetCore.NetCoreApp;
using YL.NetCore.Attributes;
using YL.Utils.Pub;
using System.Collections.Generic;

namespace KopSoftWms.Controllers
{
    public class InventoryController : BaseController
    {
        private readonly IWms_materialServices _materialServices;
        private readonly IWms_inventoryServices _inventoryServices;

        public InventoryController(
            IWms_materialServices materialServices,
            IWms_inventoryServices inventoryServices
            )
        {
            this._materialServices = materialServices;
            this._inventoryServices = inventoryServices;
        }

        [HttpGet]
        [CheckMenu]
        public IActionResult Index()
        {
            ViewBag.mList = this._materialServices.GetAllMaterials();
            ViewBag.jsonObj = this._materialServices.GetAllMaterialIdJson();
            return View();
        }

        [HttpPost]
        public string AddL(Dictionary<string, double> formdata)
        {
            var userId = UserDtoCache.UserId;

            return this._inventoryServices.WriteDictInfoToInventory(formdata, userId);
        }
    }
}